package de.dhbw.karlsruhe.picsim.gui.renderer;

import de.dhbw.karlsruhe.picsim.gui.data.SwingStackElement;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: goesen
 * Date: Apr 29, 2010
 * Time: 2:09:28 PM
 */
public class StackRenderer extends DefaultTableCellRenderer {
    @SuppressWarnings({"ReturnOfThis"})
    @Override
    public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected,
                                                   final boolean hasFocus,
                                                   final int row, final int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        final SwingStackElement element = (SwingStackElement) value;
        setBackground(element.isCurrent() ? Color.YELLOW : Color.WHITE);
        setText(String.valueOf(element.getValue().asInteger()));
        return this;
    }


}
